package cn.yilongquan.config;

import cn.yilongquan.util.MinioUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class MinioConfigValidator {
    
    @Autowired
    private MinioUtil minioUtil;
    
    @PostConstruct
    public void validateConfig() {
        try {
            // 测试MinIO连接
            minioUtil.uploadFile(new MockMultipartFile(
                "test.txt", "test.txt", "text/plain", "test".getBytes()
            ));
            System.out.println("MinIO配置验证成功");
        } catch (Exception e) {
            throw new RuntimeException("MinIO配置验证失败: " + e.getMessage(), e);
        }
    }
}